import Vue from 'vue'
import Router from 'vue-router'


// import { resolve } from 'core-js/fn/promise'

Vue.use(Router)
// import Layout from '@/components/common/Home'

/* Layout */
import Layout from '@/layout'


import chartsRouter from './modules/charts'

export const constantRoutes = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: () => import('@/views/redirect/index')
            }
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        name: 'dashboard',
        redirect: '/dashboard',
        children: [
            {
                path: 'dashboard',
                component: () => import('@/views/dashboard/index'),
                name: 'Dashboard',
                meta: {title: 'dashboard', icon: 'dashboard', affix: true}
            },

            // {
            //     path: '/RuleResult',
            //     component: resolve => require(['../views/RuleResult.vue'], resolve),
            //     meta: {title: 'RuleResult'}
            // },
            // {
            //     path: '/ParamSelectFDC',
            //     component: resolve => require(['../views/ParamSelectFDC.vue'], resolve),
            //     meta: {title: 'ParamSelectFDC'}
            // },
            // {
            //     path: '/goldenselect',
            //     component: resolve => require(['../views/goldenselect.vue'], resolve),
            //     meta: {title: 'goldenselect'}
            // },
            // {
            //     path: '/ModelSearch',
            //     component: resolve => require(['../views/ModelSearch.vue'], resolve),
            //     meta: {title: 'ModelSearch'}
            // },
            // {
            //     path: '/ParamSelectInline',
            //     component: resolve => require(['../views/ParamSelectInline.vue'], resolve),
            //     meta: {title: 'ParamSelectInline'}
            // },
        ],
    },

    {
        path: '/',
        component: Layout,
        name: 'Wafer Scoring',
        meta: {
            title: 'Wafer Scoring',
            icon: 'lock',
        },
        children: [
            {
                path: 'typesetup',
                component: () => import('../views/typesetup'),
                name: 'typesetup',
                meta: {title: 'typesetup', icon: 'documentation', affix: false}
            },
            {
                path: 'goldenselect',
                component: () => import('../views/goldenselect'),
                name: 'goldenselect',
                meta: {title: 'goldenselect', icon: 'documentation', affix: false}
            },
            {
                path: 'ruleresult',
                component: () => import('../views/ruleresult'),
                name: 'ruleresult',
                meta: {title: 'ruleresult', icon: 'documentation', affix: false}
            },
        ]
    },

    chartsRouter,


//
]

// export const asyncRoutes = [
//     {
//         chartsRouter,
//     }
// ]
const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({y: 0}),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router


//
// export default new Router({
//     routes: [
//         {
//             path: '/',
//             redirect: '/dashboard'
//         },
//         {
//             path: '/login',
//             component: resolve => require(['../views/login'], resolve)
//         },
//         {
//             path: '/',
//             component: resolve => require(['../components/common/Home.vue'], resolve),
//             children: [
//                 {
//                     path: '/dashboard',
//                     component: resolve => require(['../views/dashboard'], resolve),
//                     meta: {title: 'dashboard'}
//                 },
//                 {
//                     path: '/mix-chart',
//                     component: resolve => require(['../views/charts/mix-chart'], resolve),
//                     meta: {title: 'mix-chart'}
//                 },
//                 {
//                     path: '/RuleResult',
//                     component: resolve => require(['../views/RuleResult.vue'], resolve),
//                     meta: {title: 'RuleResult'}
//                 },
//                 {
//                     path: '/ParamSelectFDC',
//                     component: resolve => require(['../views/ParamSelectFDC.vue'], resolve),
//                     meta: {title: 'ParamSelectFDC'}
//                 },
//                 {
//                     path: '/PercentageSetup',
//                     component: resolve => require(['../views/PercentageSetup.vue'], resolve),
//                     meta: {title: 'PercentageSetup'}
//                 },
//                 {
//                     path: '/PDCA',
//                     component: resolve => require(['../views/PDCA.vue'], resolve),
//                     meta: {title: 'PDCA'}
//                 },
//                 {
//                     path: '/TypeSetup',
//                     component: resolve => require(['../views/TypeSetup.vue'], resolve),
//                     meta: {title: 'TypeSetup'}
//                 },
//                 {
//                     path: '/goldenselect',
//                     component: resolve => require(['../views/goldenselect.vue'], resolve),
//                     meta: {title: 'goldenselect'}
//                 },
//                 {
//                     path: '/ModelSearch',
//                     component: resolve => require(['../views/ModelSearch.vue'], resolve),
//                     meta: {title: 'ModelSearch'}
//                 },
//                 {
//                     path: '/ParamSelectInline',
//                     component: resolve => require(['../views/ParamSelectInline.vue'], resolve),
//                     meta: {title: 'ParamSelectInline'}
//                 },
//             ]
//         },
//     ]
// })
